<?php

class VarDef {
	private $aMessage = array(
		'name'=> 'Name',
		'email'=> 'Email',
		'subject'=> 'Subject',
		'content'=> 'Comment',
		);
	public function __construct(){

	}

	public function trans($key){
		return $this->aMessage[$key];
	}
}

class ValidLength
{
	public $header_text = 'should be ';
	public $min = 'longer than {min}';
	public $max = 'not longer than {max}';
}


class TheValidate
{
	private $aMessage = array(
		'blank'  => ' should not be blank',
		'email'  => ' should have a email type'
	);
	public function __construct(){

	}

	public function trans($params){
		$msg = '';
		if(is_array($params)){
			$msg = array();
			foreach ($params as $className => $aValue) {
				$class = new $className;
				foreach ($aValue as $key => $value) {
					$msg[] = str_replace('{' . $key . '}', $value, $class->$key);	
				}
				$msg = $class->header_text . implode(',', $msg);
			}
		} else {
			$msg = $this->aMessage[$params];
		}
		return $msg;
	}	
}
?>